﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using SouthernLand.Common.BOL.NhaDat;
using SouthernLand.Common.Untilities;

namespace SouthernLand.WebMaster.Land
{
    public partial class TinhManagement : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
            btSave.Click += new EventHandler(btSave_Click);
            btCancel.Click += new EventHandler(btCancel_Click);
        }

        void btCancel_Click(object sender, EventArgs e)
        {
            txtCateOrder.Text = string.Empty;
            txtQuanHuyenName.Text = string.Empty;
            txtQuanHuyenName_en.Text = string.Empty;
        }

        void btSave_Click(object sender, EventArgs e)
        {
            int success = QuanHuyen.Insert(new QuanHuyen()
            {
                TenQuanHuyen = txtQuanHuyenName.Text,
                TenQuanHuyen_en = txtQuanHuyenName_en.Text,
                TinhThanhID = ConvertUtility.ToInt32(dlTinhthanh.SelectedItem.Value),
                ViTri = ConvertUtility.ToInt32(txtCateOrder.Text)
            });
            if (success > 0)
            {
                lblMsg.Text = "Thêm huyện mới thành công!";
            }
            else
            {
                lblMsg.Text = "Có lỗi trong quá trình thêm mới.";
            }
            
        }
    }
}